home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1817 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: oxy.rust.net!usenet
  2. From: ebennett@rust.net
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q: realloc->free?
  5. Date: Wed, 17 Jan 1996 05:58:08 GMT
  6. Organization: Rust Net - High Speed Internet in Detroit  810-642-2276
  7. Message-ID: <4dhoig$ioj@oxy.rust.net>
  8. References: <4daa2e$oh5@axe.netdoor.com> <4df2ud$706@oxy.rust.net> <30fb133c.1128448@nntp.ix.netcom.com>
  9. NNTP-Posting-Host: liv-10.rust.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. miker3@ix.netcom.com (Mike Rubenstein) wrote:
  13.  
  14. >ebennett@rust.net wrote:
  15.  
  16. >|>esargent@netdoor.com (Eric Sargent) wrote:
  17. >|>
  18. >|>
  19. >|>
  20. > Stuff Deleted
  21. >|>realloc() will free the old block.  It is perfectly legal to say
  22. >|>
  23. >|>  a = realloc(a, newsize);
  24. >|>
  25. >|>No memory loss should occur from this.
  26.  
  27. >What if realloc() fails?  This will assign NULL to a and the old value
  28. >will be lost unless it's been stored in some other variable.
  29.  
  30. An excellent point, sir!  I have never had occasion to use realloc
  31. myself, and had not thought about the consequences.  So, although
  32. legal to do as I said, it is admittedly foolish.
  33.  
  34. Earl
  35.  
  36.  
  37.